package cn.edu.zjicm.wordsnet_d.util;

import android.content.Context;
import cn.edu.zjicm.wordsnet_d.datapersistent.AppPreference;

public class NightModeUtil {
	public final static int THEME_SUN = 1;
	public final static int THEME_NIGHT = 2;

	private static int mode = THEME_SUN;
	private static boolean isNightModeNow = false;

	// public static void changeToTheme(Activity activity) {
	// // int theme = getDayNightMode() == THEME_SUN ? THEME_NIGHT : THEME_SUN;
	// // if(getDayNightMode())
	// // setDayNightMode(theme);
	// // activity.finish();
	// // activity.startActivity(new Intent(activity, activity.getClass()));
	//
	// Intent intent = activity.getIntent();
	// activity.overridePendingTransition(0, 0);
	// intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
	// activity.finish();
	// activity.overridePendingTransition(0, 0);
	// activity.startActivity(intent);
	// }

	// public static void onActivityCreateSetTheme(Activity activity) {
	// switch (getDayNightMode()) {
	// case THEME_SUN:
	// activity.setTheme(R.style.dayTimeMode);
	// break;
	// case THEME_NIGHT:
	// activity.setTheme(R.style.nightTimeMode);
	// break;
	// default:
	// break;
	// }
	// }

	public static int getDayNightMode(Context mContext) {
		mode = AppPreference.getDayNightMode(mContext);
		if (mode == THEME_NIGHT) {
			isNightModeNow = true;
		} else
			isNightModeNow = false;
		return mode;
	}

	public static void setDayNightMode(Context mContext,int theme) {
		mode = theme;
		if (mode == THEME_NIGHT) {
			isNightModeNow = true;
		} else
			isNightModeNow = false;
		AppPreference.setDayNightMode(mContext, mode);
	}

	public static boolean isNightModeNow() {
		return isNightModeNow;
	}

}
